package designpatterns.strategy.code;

/**
 * 简单工厂
 */
public class StrategySimpleFactory {

    /**
     * 通过策略名称获取对应的策略
     *
     * @param strategyName
     * @return
     */
    public Strategy getStrategy(String strategyName) {
        switch (strategyName) {
            case "+":
                return new Add();
            case "-":
                return new Sub();
            case "*":
                return new Mul();
            case "/":
                return new Div();
//            case "%":
//                return new Mod();
            default:
                throw new UnsupportedOperationException("strategyName not found");
        }
    }

}
